import React, {Component} from "react"
import "../../../asset/css/mine/login.css"
class Login extends Component{
    constructor(){
        super()
        this.state={
            loginName:"",
            loginPwd:""
        }
    }
    checkSubmit(e){
        e.preventDefault()
        // console.log(11111)
    }
    Login(){
      
        let {username,password}=this.props
       
        let {loginName,loginPwd} =this.state
        console.log(username,password,loginName,loginPwd)
        if(username==this.state.loginName&&password==this.state.loginPwd){
           alert("登录成功")
           let {changeType}=this.props
           let {loginSubmit}=this.props
           console.log(this.props)
           let num=1
            // setter
           localStorage.setItem('myData', num);
            // getter
        // localStorage.getItem('myData');
            changeType(num)
            loginSubmit(num)
        }
    }
    chek_loginName(e){
        let val=e.target.value
        this.setState(state=>{
            state.loginName=val
        })
       console.log(this.state.loginName)
        
        
    }
    chek_loginPwd(e){
        let val=e.target.value
        this.setState(state=>{
            state.loginPwd=val
        })
        // if(this.state.username==)
        console.log(this.state.loginPwd)
        
    }
    render(){
   
        return(
            <div className="loginContainer">
              <div className="form">
                <form onSubmit={this.checkSubmit}>
                    <div className="username">
                  <input type="text" placeholder="用户姓名" maxlengeth="11" onChange={e=>this.chek_loginName(e)} />
                  
                    </div>
                    <div className="password">
                        <input type="password" placeholder="用户密码" maxlengeth="11" onChange={e=>this.chek_loginPwd(e)} />
                    </div>
                    <div className="btn">
                        <button className="submitBtn" onClick={this.Login.bind(this)} >登录</button>
                    </div>
                </form>
              </div>
            </div>
        )
    }
}
export default Login